package com.jay.base.thread.book;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by caoyuan7 on 2019/7/24.
 * 公平锁
 */
public class FairLock implements Runnable {
    public static ReentrantLock fairLock = new ReentrantLock(true);

    @Override
    public void run() {
        while (true){
            try {
                fairLock.lock();
                System.out.println(Thread.currentThread().getName()+":获得锁");
            }finally {
                fairLock.unlock();
            }
        }
    }
    public static void main(String args[]){
      String arr[]={"我","我我","我我我"};
        List list = Arrays.asList(arr);
        arr[1] = "爱上";
        list.set(2,"上海");
        System.out.println(Arrays.toString(arr));
        System.out.println(list.toString());
    }
}
